package chain_of_responsibility

import "fmt"

type Request interface {
}

type Handler interface {
	SetNext(handler Handler)
	Handle(request Request)
}

type Handler1 struct {
	next Handler
}

func (h *Handler1) SetNext(handler Handler) {
	h.next = handler
}

func (h *Handler1) Handle(request Request) {
	fmt.Println("Handler1 Handle()")
	if h.next != nil {
		h.next.Handle(request)
	}
}

type Handler2 struct {
	next Handler
}

func (h *Handler2) SetNext(handler Handler) {
	h.next = handler
}

func (h *Handler2) Handle(request Request) {
	fmt.Println("Handler2 Handle()")
	if h.next != nil {
		h.next.Handle(request)
	}
}
